
package com.hy.util;

import com.hy.admin.pojo.User;
import lombok.extern.slf4j.Slf4j;

/**
 * @author Lenovo
 * @description 工具类，用于在当前线程中存储和获取用户信息
 * @createDate 2025-03-04 18:50:51
 */
@Slf4j
public class AuthContextUtil {

    // 创建一个ThreadLocal对象，用于存储当前线程的用户信息
    private static final ThreadLocal<User> currentUser = new ThreadLocal<>();

    public static void set(User user) {
        currentUser.set(user);
    }

    public static User get() {
        return currentUser.get();
    }

    public static void remove() {
        currentUser.remove();
    }
}
